<?php
require_once(dirname(__FILE__)."/config.php");
  $conns=@mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
  @mysql_select_db($cfg_dbname);
  mysql_query("set names $cfg_db_language")
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<title>留言列表</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
<script>
function CheckOthers(form)
{
   for (var i=0;i<form.elements.length;i++)
   {
      var e = form.elements[i];
      if (e.checked==false)
      {
	     e.checked = true;
      }
      else
      {
	     e.checked = false;
      }
   }
}

function CheckAll(form)
{
   for (var i=0;i<form.elements.length;i++)
   {
      var e = form.elements[i];
      e.checked = true;
   }
}
//相关条目删除提示------------------------------------------------------------
function ConfirmDel(message)
{
   if (confirm(message))
   {
      document.myform.submit()
   }
}
function ConfirmDel_1(message)
{
   if (confirm(message))
   {
      document.myform2.submit()
   }
}

//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.myform.id.value) return document.myform.id.value;
	for(i=0;i<document.myform.id.length;i++)
	{
		if(document.myform.id[i].checked)
		{
			if(allSel=="")
				allSel=document.myform.id[i].value;
			else
				allSel=allSel+"`"+document.myform.id[i].value;
		}
	}
	return allSel;
}
</script>
</head>
<?php
if ($_GET['id']<>"")
{
$dsql->ExecuteNoneQuery('delete from #@__message where id='.$_GET['id'].'');
ShowMsg('删除成功！','message_main.php?page='.$_GET["page"]);
exit();
}
if($_GET['post']=="all")
{
if($_POST['del_id']!="")
{ 
$ids=$_POST['del_id'];
$ids=implode(",", $ids);  //implode函数 把数组元素组合为一个字符串。
$dsql->ExecuteNoneQuery('delete from #@__message where id in('.$ids.')');
ShowMsg('全选删除成功！','message_main.php?page='.$_GET["page"]);
exit();
  }else
 { 
  echo("<script type='text/javascript'>alert('请先选择项目！');history.back();</script>"); 
 }
} 
?>
<body background='images/allbg.gif' leftmargin='8' topmargin='8'>
<!--  内容列表   -->
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center">
<form  name="myform"  method="post" action="?post=all" >
<tr bgcolor="#E7E7E7" >
	<td height="28" colspan="11" background="images/tbg.gif" style="padding-left:10px;">留言列表</td>
</tr>
<tr align="center" bgcolor="#FBFCE2" height="25">
    <td width="4%">选择</td>
	<td width="5%">ID</td>
    <td width="9%">来源</td>
	<td width="11%">姓名</td>
    <td width="7%">性别</td>
    <td width="16%">手机</td>
    <td width="16%">来源IP</td>
    <td width="14%">提交时间</td>
    <td width="8%">是否查看</td>
	<td width="10%">操作</td>
</tr>
<?php
$sql="select * from ".$cfg_dbprefix."message";
$rst=mysql_query($sql);
$totalnum=@mysql_num_rows($rst);
$pagesize=10;
$page=$_GET['page'];
if($page==''){
	$page=1;
}
$begin=($page-1)*$pagesize;
$pagecount=ceil($totalnum/$pagesize);

$sql="select * from ".$cfg_dbprefix."message order by chuli desc,datetime desc limit $begin,$pagesize";
 $shuchu=mysql_query($sql);
while($info=@mysql_fetch_array($shuchu))
{
?>
<tr align="center" bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="25">
    <td><input name="del_id[]" type="checkbox" id="del_id[]" value="<?php echo $info['id']?>"></td>
    <td><?php echo $info['id']?></td>
    <td><?php if($info['laiyuan']=="中文来源"){echo "<samp style='color:#ff3300;'>".$info['laiyuan']."</samp>";}else{echo "<samp style='color:#F39;'>".$info['laiyuan']."</samp>";}?></td>
	<td><?php echo $info['username']?></td>
	<td><?php echo $info['sex']?></td>
    <td><?php echo $info['shouji']?></td>
    <td><?php echo $info['ip']?></td>
    <td><?php echo $info['dtime']?></td>
    <td><?php if($info['chuli']==1){echo "<samp style='color:#CC9900'>未处理</samp>";}else{ echo "<samp style='color:#ff3300'>已处理</samp>";}?></td>
	<td><a href="message_k.php?id=<?php echo $info['id']?>&page=<?php echo $_GET['page'];?>" title="详细查看">查看</a> | <a href="?id=<?php echo $info['id']?>&page=<?php echo $_GET['page'];?>" title="删除">删除</a></td>
</tr>
<?php
}
?>
<tr bgcolor="#ffffff">
<td height="25" colspan="11" align="center">
	页数<samp style="color:#f30;"><?php echo $page?></samp>/<?php echo $pagecount;?>页 每页显示<?php echo $pagesize;?>条  共<?php echo $totalnum;?>条信息 <a href="<?php echo $_SERVER['PHP_SELF']?>?page=1">首页</a>&nbsp;&nbsp;<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php  if($page>1) echo  $page-1; else  echo $page=1;?>">上一页</a>&nbsp;&nbsp;<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php if($page<$pagecount-1) echo $page+1; else echo $pagecount; ?>">下一页</a> &nbsp;&nbsp;<a href="<?php echo $_SERVER['PHP_SELF']?>?page=<?php echo $pagecount;?>">尾页</a>
</td>
</tr>
<tr bgcolor="#ffffff">
<td height="36" colspan="11">
	&nbsp;
    <input type='button' class="coolbg np" onClick="CheckOthers(this.form)"  value='全反' />
    <input type='button' class="coolbg np" onClick="ConfirmDel('您真的要删除这些信息吗？');" value='删除' />
    <input type='button' class="coolbg np" onclick="location.reload();" value='刷新' />
</td>
</tr>
</form>
</table>
<?
mysql_close();
?>
</body>
</html>